package com.vimhe.easyimport.example;

import com.vimhe.easyimport.ImportManager;
import com.vimhe.easyimport.config.ImportConfig;
import com.vimhe.easyimport.config.XmlConfigSource;
import com.vimhe.easyimport.processor.AbstractDataProcessor;

import java.util.Map;

/**
 * 数据导入示例
 *
 * @author Vimhe
 */
public class EasyImport {

    public static void main(String[] args) throws Exception {
        EasyImport easyImport = new EasyImport();
        easyImport.init();
    }

    private void init() throws Exception {
        ImportManager.Builder builder = new ImportManager.Builder();
        builder.setImportConfig(new ImportConfig(new XmlConfigSource()))
                .setFileName("")
                .setFilePath("")
                .addDataProcessor(new MyDataProcessor());
        ImportManager importManager = builder.build();
        importManager.run();
    }

    /**
     * 自己实现一个数据处理器，
     */
    private class MyDataProcessor extends AbstractDataProcessor {
        @Override
        public void processRow(int sheetIndex, int rowIndex, Map<String, Object> rowValue) {
            System.out.println(rowValue);
        }
    }

}
